package com.furong.controller;

import com.furong.exception.BusinessException;
import com.furong.exception.SystemException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


@RestControllerAdvice
public class ProjectExceptionAdvice {
//    处理SystemException异常
    @ExceptionHandler(SystemException.class)
    public Result doSystemException(SystemException ex){
        return new Result(ex.getCode(), null, ex.getMessage());
    }

    @ExceptionHandler(BusinessException.class)
    public Result doBusinessException(BusinessException ex) {
        return new Result(ex.getCode(), null, ex.getMessage());
    }

    @ExceptionHandler
    public Result doException(Exception ex){
        System.out.println("嘿嘿,异常你哪里跑！" + ex);
        return new Result(666, null, "嘿嘿,异常你哪里跑！");
    }
}
